<template>
	
	<view class="container-box">
		<label class="change-view" @click="changeAllState">
			<radio :checked="isFullCheck" color="#c00000"></radio>
			<text>全选</text>
		</label>
		
		<view class="amount-box">
			合计：<text class="amount">￥{{totalPrice}}</text>
		</view>
		
		<view class="btn-settle" @click="settlement">结算({{checkedCount}})</view>
	</view>
</template>

<script>
	
	import { mapGetters, mapMutations } from 'vuex'
	
	export default {
		name:"my-settle",
		data() {
			return {
				
			};
		},
		
		computed: {
			...mapGetters('m_cart', ['checkedCount', 'total', 'totalPrice']),
			...mapGetters('m_user', ['token'], ['addstr']),
			
			isFullCheck() {
				return this.total === this.checkedCount
			},
		},
		
		methods: {
			
			...mapMutations('m_cart', ['updateAllGoodsState']),
			
			changeAllState() {
				this.updateAllGoodsState(!this.isFullCheck)
			},
			
			settlement() {
				if (!this.checkedCount) return uni.$showMsg('请选择要结算的商品！')
				
				if (!this.addstr) return uni.$showMsg('请选择收货地址！')
				
				if (!this.token) return uni.$showMsg('请登录！')
			},
			
			
		}
		
	}
</script>

<style lang="scss">

	.container-box {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		display: flex;
		height: 50px;
		font-size: 15px;
		justify-content: space-around;
		align-items: center;
		background-color: #FFFFFF;
		padding-left: -5px;
		.change-view {
			display: flex;
			align-items: center;
		}
		
		.amount-box {
			.amount {
				color: #c00000;
				font-weight: bold;
			}
		}
		
		.btn-settle {
			background-color: #C00000;
			height: 50px;
			color: white;
			line-height: 50px;
			min-width: 100px;
			text-align: center;
		}
	}

</style>
